<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        html {
            width: 100%;
            height: 100%;
        }

        body {
            width: 100%;
            height: 1500px;
        }

        #dv {
            width: 50px;
            height: 50px;
            background-color: hotpink;
            position: fixed;
            right: 30px;
            bottom: 30px;
            display: none;
        }
    </style>
</head>

<body>
    <div id="dv"></div>
</body>

</html>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
<script>
    function srl() {
        // console.log(height);
        $(window).scroll(function () {
            let height = $(window).scrollTop()
            if (height >= 600) {
                // console.log('111');
                $('#dv').fadeIn(300)
            } else {
                $('#dv').fadeOut(300)
            }
        })
    }
    srl()
    $('#dv').click(function(){
        // console.log('1');
        $('html').animate({
            scrollTop:0
        },600)
    })
</script>